    var keyProductMaintance = {
        /**
         * 绑定事件
         */
        bindEvent: function () {
        	
            $(".competion-search-btn").unbind().on("click", function () {
                common.currentPage = 1;
                var textFieldValue = $("#productkeyInput").val();
                var orderkey = window.sessionStorage.getItem("proudrctOrderKey");
                if (orderkey == undefined || orderkey == "" || orderkey == null) {
                    keyProductMaintance.api_queryShellProductWithKeyword(textFieldValue);
                } else {
                    keyProductMaintance.api_queryShellProductWithKeyword(textFieldValue,orderkey);
                }
            });
            // $(".waitcallback-uap").unbind().on("click", function () {
                // window.sessionStorage.setItem("proudrctOrderKey",$(this).attr("order-key"));
            	// window.sessionStorage.setItem("proudrctDataType",$(this).attr("data-type"));
                // keyProductMaintance.api_queryShellProductWithKeyword($("#productkeyInput").val(), $(this).attr("order-key"), $(this).attr("data-type"));
            // });
            $(".col-md-1").unbind().on("click", function () {
            	var down = "../admin/images/down.png";
            	var up ="../admin/images/uap.png";
            	$(".col-md-1 a").html("");
            	var type = $(this).attr("data-type");
            	if (type) {
            		if (type == "ASC") {
	            		$(this).attr("data-type","DESC");
	            		$(this).children('a').html('<img src="'+up+'"/>');
            		}else if(type == "DESC"){
            			$(this).attr("data-type","ASC");
	            		$(this).children('a').html('<img src="'+down+'"/>');
            		}else{
            			$(this).attr("data-type","DESC");
	            		$(this).children('a').html('<img src="'+up+'"/>');
	            		type= "ASC";
            		}	
            	}else{
            		$(this).attr("data-type","DESC");
            		$(this).children('a').html('<img src="'+up+'"/>');
            		type= "ASC";
            	}
            	window.sessionStorage.setItem("proudrctOrderKey",$(this).attr("order-key"));
            	window.sessionStorage.setItem("proudrctDataType",type);
            	keyProductMaintance.api_queryShellProductWithKeyword($("#productkeyInput").val(), $(this).attr("order-key"), type);
            });
        },
        /**
         * 初始化
         */
        init: function () {
            common.currentPage = 1;
            keyProductMaintance.api_queryShellProductWithKeyword($("#productkeyInput").val());
            $(".col-md-1 a").html("");
            var str = "../admin/images/uap.png";
            $("#productcol-md-1 a").html('<img src="'+str+'"/>');
        },
        /**
         * API请求--查询
         */
        api_queryShellProductWithKeyword: function (keyword, orderkey, orderrule) {
            var url = "/shellProduct/pageQuery";
            var functionParam = {
                "pk_user": window.localStorage.userid,
                "pageSize": common.pageSize,
                "pageNum": common.currentPage,
                "orderkey": orderkey ? orderkey : "product_name",
                "orderrule": orderrule ? orderrule : "ASC",
                "name": keyword
            };
            common.showLoading();
            common.interfaceAjaxFunction(url, functionParam, this.queryShellProductSuccess, true);
        },
        /**
         * API请求--删除
         */
        api_deleteShellProductWithKey: function (primeryKey) {
            var url = "/shellProduct/delete";
            var functionParam = {
                "pk_user": window.localStorage.userid,
                "pk": primeryKey
            };
            common.interfaceAjaxFunction(url, functionParam, this.deleteShellProductSucess, true);
            common.showLoading();
        },
        /**
         * 查询接口回调
         */
        queryShellProductSuccess: function (res) {
            common.hideLoading();
            //console.log("产品关键字维护查询接口返回数据: ", JSON.stringify(res));
            if (res.status!=0) {
                common.showTip(res.message);
                return;
            } else {
                //更新UI
                keyProductMaintance.updateUI(res);
            }
        },
        /**
         * 删除接口回调
         */
        deleteShellProductSucess: function (res) {
            common.hideLoading();
            if (res.status!=0) {
                common.showTip(res.message);
            } else {
            	keyProductMaintance.init();
                // keyProductMaintance.api_queryShellProductWithKeyword($("#productkeyInput").val());
            }
        },
        /**
         * 更新UI
         */
        updateUI: function (result) {
            var html = "";
            var dataArray = result["data"];
            if(dataArray.length > 0){
            	for (var i = 0; i < dataArray.length; i++) {
                    var dic = dataArray[i];
                    var product_name = dic["product_name"];
                    var create_date = dic["dtcreate"];
                    var modify_date = dic["fW_TS"];
                    var pkid = dic["pk_product"];
                    var pkcode = dic["product_code"];
                    var create_name = dic["create_name"];
                    if (create_name == undefined || create_name == "") {
                        create_name = "";
                    }
                    var update_date = dic["update_date"];
                    if (update_date == undefined || update_date == "") {
                        update_date = "";
                    }
                    var update_name = dic["update_name"];
                    if (update_name == undefined || update_name == "") {
                        update_name = "";
                    }
                    var sealmark = dic["sealmark"];
                    html += '<tr>'
                        + '<td id="productName">' + product_name + '</td>'
                        + '<td >' + sealmark + '</td>'
                        + '<td >' + create_name + '</td>'
                        + '<td >' + create_date + '</td>'
                        + '<td >' + update_name + '</td>'
                        + '<td >' + update_date + '</td>'
                        + '<td><div class="operation"><a id="btn_edit" class="btn-editor" eidtPkid=' + pkid + '></a><a id="btn-delete" class="btn-delete" product_name="' + product_name + '" pkid="' + pkid + '"></a></div></td>'
                        + '</tr>';
                }
                //刷新表格
                $("#keyProductMaintanceTable").html(html);
            }else{
            	$("#keyProductMaintanceTable").html("<tr><td colspan='7'>暂无产品数据</td></tr>");
            }
            
            /**
             * 编辑按钮绑定事件
             */
            $(".btn-editor").unbind().on("click", function () {
                var currentEditPkid = $(this).attr("eidtPkid");
                var row = $(this).parent().parent().parent()[0].children[0];
                var colom = $(this).parent().parent().parent()[0].children[1];
                //console.log("++++++++++++++++++++++++++",$(colom).html());
                var jsonStr = JSON.stringify({ "currentEditPkid": currentEditPkid, "currentProductName": $(row).html(), "currentProductStatus":$(colom).html()});
                window.sessionStorage.setItem("editParam", jsonStr);
                window.sessionStorage.setItem("modeSwitch", 1);
                //页面一打开就执行，放入ready是为了layer所需配件（css、扩展模块）加载完毕
                layer.ready(function () {
                    //增加编辑
                    layer.open({
                        type: 2,
                        //skin: 'layui-layer-lan',
                        title: '编辑',
                        fix: false,
                        shadeClose: true,
                        maxmin: true,
                        area: ['1000px', '500px'],
                        content: 'html/keyProductMaintanceAdd.html'
                    });
                });
            });
            /**
             * 删除按钮绑定事件
             */
            $(".btn-delete").unbind().on("click", function () {
                var pk_id = $(this).attr("pkid");
                var product_name = $(this).attr("product_name");
                layer.confirm("您确认要删除产品："+product_name+"吗？", {area: ['400px', '200px'],title:'删除'}, function () {
                    keyProductMaintance.api_deleteShellProductWithKey(pk_id);
                    layer.msg("删除成功");
                }, function () {
                });
            });
            /**
             * 绑定新增按钮点击事件
             */
            $("#create-row").unbind().on("click", function () {
                window.sessionStorage.setItem("modeSwitch", 2);
                //页面一打开就执行，放入ready是为了layer所需配件（css、扩展模块）加载完毕
                layer.ready(function () {
                    //增加编辑
                    layer.open({
                        type: 2,
                        //skin: 'layui-layer-lan',
                        title: '新增商品',
                        fix: false,
                        shadeClose: true,
                        maxmin: true,
                        area: ['1000px', '500px'],
                        content: 'html/keyProductMaintanceAdd.html',
                    });
                });
            });
            //产生分页结构
            common.getPageDivide(result.count, "pageDivideContainer", keyProductMaintance.updateList);
        },
        /**
        * 添加成功回调
        */
        addSucessCallBackFunction: function (index, res) {
            common.hideLoading();
            if (res.status != 0) {
                layer.msg(res.message);
            } else {
                //调用父页面的查询
                keyProductMaintance.api_queryShellProductWithKeyword($("#productkeyInput").val());
                window.sessionStorage.setItem("modeSwitch", 0);
                layer.msg("修改成功");
            }
        },
        updateList: function () {
        	var orderkey = window.sessionStorage.proudrctOrderKey  ;
            //console.log("+++++++++++++++______________________________",orderkey);
            var orderrule = window.sessionStorage.proudrctDataType  ;
            //转圈
            common.showLoading();
            var url = "/shellProduct/pageQuery";
            var functionParam = {
                "pk_user": window.localStorage.userid,
                "pageSize": common.pageSize,
                "pageNum": common.currentPage,
                "orderkey": orderkey ? orderkey : "product_name",
                "orderrule": orderrule ? orderrule : "DESC",
                "name": $("#productkeyInput").val()
            };
            common.interfaceAjaxFunction(url, functionParam, keyProductMaintance.queryShellProductSuccess, true,"",false);
        },
        initialize : function(){
        	keyProductMaintance.init();
            keyProductMaintance.bindEvent();
        }
    };
   /* $(document).ready(function () {
        keyProductMaintance.init();
        keyProductMaintance.bindEvent();
    });*/
